package com.wanmait.translate.configuration.configuration;

import com.wanmait.translate.configuration.interceptor.MvcInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*
 * @Author huweibin
 * @Description mvc配置类
 * @Date 9:42 2020/10/30
 **/
@Configuration
public class MvcConfiguration implements WebMvcConfigurer{
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        WebMvcConfigurer.super.addInterceptors(registry);
        registry.addInterceptor(
                new MvcInterceptor())
                .addPathPatterns("/**")//拦截所有请求
                .excludePathPatterns("/static/**");//静态资源放行
    }
    //用于配置静态页面跳转
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        //登录及主页
        registry.addViewController("/index").setViewName("index");
        registry.addViewController("/login").setViewName("index");
        //部门模块
        registry.addViewController("/system/department/departmentContent").setViewName("system/department/departmentContent");
        registry.addViewController("/system/department/departmentTree").setViewName("system/department/departmentTree");
        registry.addViewController("/system/user/userTable").setViewName("system/user/userTable");
        //岗位模块
        registry.addViewController("/system/post/postContent").setViewName("system/post/postContent");
        registry.addViewController("/system/post/postInput").setViewName("system/post/postInput");
        registry.addViewController("/system/post/postTree").setViewName("system/post/postTree");
        //菜单模块
        registry.addViewController("/system/menu/menuContent").setViewName("/system/menu/menuContent");
        registry.addViewController("/system/menu/menuInput").setViewName("/system/menu/menuInput");
        registry.addViewController("/system/menu/menuTree").setViewName("/system/menu/menuTree");

    }
}
